package com.kingdee.eas.fi.gl;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.eventbus.event.action.KDActionEvent;
import com.kingdee.bos.webframework.exception.WafException;
import com.kingdee.bos.webframework.json.JSONUtils;
import com.kingdee.bos.webframework.dynamic.handler.AbstractWebEventHandler;
import com.kingdee.bos.eventbus.event.action.IActionEventHandler;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.jiu.VoucherFoundMsgInfo;
import com.kingdee.eas.custom.jiu.VoucherPortFacade;
import com.kingdee.eas.custom.jiu.VoucherPortFacadeFactory;

public class ImpVoucherHandler extends AbstractWebEventHandler implements IActionEventHandler {
	public void onAction(KDActionEvent event) throws WafException,BOSException {
		JSONArray ja=new JSONArray();
		String ids=event.getReqeustContext().getHttpServletRequest().getParameter("ids");
		JSONObject json=JSONObject.parseObject(ids);
		
		for(String key:json.keySet()){
			IObjectPK voucherId=new ObjectUuidPK(key);
			JSONObject msg=new JSONObject();
			msg.put("number", json.get(key));
			try {
				VoucherFoundMsgInfo msgInfo=(VoucherFoundMsgInfo) VoucherPortFacadeFactory.getRemoteInstance().impVoucher(voucherId);
				
				msg.put("succeed", msgInfo.isIsSucceed());
				msg.put("msg", msgInfo.getLogmsg());
				ja.add(msg);
			} catch (EASBizException e) {
				e.printStackTrace();
			}
		}
		
		JSONUtils.SUCCESS(ja);
	}
}